home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / UTIL / MEMORY / OLD / MEM208SRC / FSLib / c / _Open < prev    next >
Text File  |  1993-08-22  |  2KB  |  56 lines

  1. /* Original code (c) Acorn Computers Ltd, 1992-3 */
  2.  
  3. /* $Id: c._Open 3.1 93/03/09 23:25:44 brian Exp $ */
  4. #include "FS.h"
  5.  
  6. #define BUFFER_SIZE 1024
  7.  
  8. _kernel_oserror *fsentry_open( FSEntry_Open_Parameter *parm )
  9. {
  10.   _kernel_oserror *err;
  11.   FileEntry *fse=(FileEntry*)parm->open_definition.handle;
  12.   WHICH how;
  13. #ifdef DEBUG
  14.   printf("Open(%d)\n",parm->open_definition.reason);
  15. #endif
  16.   special_field = parm->open_definition.special_field;
  17.   switch ( parm->open_definition.reason )
  18.   {
  19.   case FSEntry_Open_Reason_Update:      how = OPENUP;   break;
  20.   case FSEntry_Open_Reason_OpenRead:    how = OPENIN;   break;
  21.   case FSEntry_Open_Reason_CreateUpdate:how = CREATE;   break;
  22.   default:
  23.           return ERR(mb_BadParameters);
  24.   }
  25.     err = FileEntry_Open( NULL, parm->open_definition.filename, how, &fse );
  26.     if ( err )
  27.     { parm->open_result.handle = NULL;
  28.       if ( err!=ERR(mb_FileNotFound) )
  29.         return err;
  30.     }
  31.     else
  32.     { FileDesc d = FileEntry_Desc( fse );
  33.       int i;
  34.       parm->open_result.handle = (FileSystemHandle)fse;
  35.       i=0;
  36.       if (d.attr&Attr_W && parm->open_definition.reason!=FSEntry_Open_Reason_OpenRead)
  37.                          i|=InformationWord_WritePermitted;
  38.       if (d.attr&Attr_R) i|=InformationWord_ReadPermitted;
  39.       if (!d.buffered && !d.noosgbpb)
  40.                          i|=InformationWord_UnbufferedOS_GBPBSupported;
  41.       if (d.interactive) i|=InformationWord_StreamIsInteractive;
  42.       if (2==d.type)     i|=InformationWord_ObjectIsDirectory;
  43.       parm->open_result.information_word=i;
  44.       if ( d.buffered )
  45.       { parm->open_result.buffer_size=BUFFER_SIZE;
  46.         parm->open_result.file_extent=d.length;
  47.         parm->open_result.allocated_space=FileEntry_Allocated(fse);
  48.       }
  49.       else
  50.         parm->open_result.buffer_size=0;
  51.     }
  52.     return NULL;
  53.  
  54. }
  55.  
  56.